import { createWebHistory, createRouter } from 'vue-router'

import HomeView from '../views/home/index.vue'
import Detail from '../views/detail.vue'
import Login from '../views/login.vue'

import Home from '../views/home/home.vue'
import Sort from '../views/home/sort.vue'
import Cart from '../views/home/cart.vue'
import My from '../views/home/my.vue'

const routes = [
    { path: '/', redirect: '/home' },
    {
        path: '/home',
        component: HomeView,
        children: [
            {
                path: '/home',
                component: Home,
            },
            {
                path: '/sort',
                component: Sort,
            },
            {
                path: '/cart',
                component: Cart,
            },
            {
                path: '/my',
                component: My,
            },
        ]
    },
    {
        path: '/detail',
        component: Detail
    },
    {
        path: '/login',
        component: Login
    },
]

export const router = createRouter({
    history: createWebHistory(),
    routes,
})